#include "CSDLFont.h"

namespace FBShells {
	CSDLFont::CSDLFont(std::string font, int size) : m_pointsize(size) {
		loadFont(font);
	}
	
	CSDLFont::~CSDLFont() {
		deleteFont();
	}

	bool CSDLFont::loadFont(std::string font) {
		const char* lawl = font.c_str();
		m_sdlfont = TTF_OpenFont(lawl,m_pointsize);
		if(!m_sdlfont) 
	    	printf("Unable to load font: %s %s \n", font.c_str(), TTF_GetError());
	}
	
	void CSDLFont::deleteFont() {
		TTF_CloseFont(m_sdlfont);
	}
	
	SDL_Surface* CSDLFont::drawString(std::string text) {
		SDL_Color tmpfontcolor = {255,255,255,255};
		SDL_Color tmpfontbg = {255,255,255,255};
		SDL_Surface* tmpsurf = TTF_RenderText_Blended(m_sdlfont, text.c_str(), tmpfontcolor);
		return tmpsurf; 
	}
}
